<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">标题</h1>
		</header>
		<div class="mui-content">
			<button id="btn" type="button" class="mui-btn mui-btn-blue mui-btn-block">按钮</button>
			<button id="btn2" type="button" class="mui-btn mui-btn-yellow mui-btn-block">按钮</button>
		</div>
		<script src="../../js/commons-blue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init()
			var task = plus.uploader.createUpload("http://192.168.1.112:9090/a", {
					method: "get",
					blocksize: 204800,
					priority: 100
				},
				function(t, status) {
					console.log(t.responseText)
					console.log('到这了')
					// 上传完成
					if(status == 200) {
						alert("Upload success: " + t.url);
					} else {
						alert("Upload failed: " + status);
					}
				}
			);
			document.getElementById('btn2').addEventListener('tap', function() {
				//task.addEventListener( "statechanged", onStateChanged, false );
				task.start();
			})
			mui.plusReady(function() {
				CommonsFunction.setHeaderBackground();
			})
			document.getElementById('btn').addEventListener('tap', function() {
				mui.ajax('http://192.168.1.112:9090/a+1', {
					type: 'get', //HTTP请求类型
					timeout: 1000, //超时时间设置为10秒；
					success: function(data, status, xhr) {
						console.log('a请求成功');
					},
					error: function(xhr, type, errorThrown) {
						//console.log('a错误' + xhr.status);
						console.log(xhr.responseText)
						/*for(var i in xhr) {
							console.log(i + ':' + xhr[i]);
						}*/
					}
				});
				mui.ajax('http://192.168.1.112:9090/b', {
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						console.log('b请求成功');
					},
					error: function(xhr, type, errorThrown) {
						console.log('b错误' + xhr.status);
					}
				});
			});
		</script>
	</body>

</html>